package com.esri.core.tasks.ags;

import com.esri.core.internal.tasks.TaskListener;
import com.esri.core.map.CallbackListener;

/* loaded from: classes.dex */
public class TaskCallbackListener<T> implements TaskListener<T> {
    CallbackListener<T> _callback;
    boolean _onEDT;

    private TaskCallbackListener(CallbackListener<T> callbackListener, boolean z) {
        this._onEDT = false;
        if (callbackListener == null) {
            throw new RuntimeException("callback cannot be null.");
        }
        this._callback = callbackListener;
        this._onEDT = z;
    }

    public TaskCallbackListener(CallbackListener<T> callbackListener) {
        this(callbackListener, false);
    }

    @Override // com.esri.core.internal.tasks.TaskListener
    public void onCompletion(short s, final T t) {
        if (this._onEDT) {
            new Thread(new Runnable() { // from class: com.esri.core.tasks.ags.TaskCallbackListener.1
                /* JADX WARN: Multi-variable type inference failed */
                @Override // java.lang.Runnable
                public void run() {
                    TaskCallbackListener.this._callback.onCallback(t);
                }
            }).start();
        } else {
            this._callback.onCallback(t);
        }
    }

    @Override // com.esri.core.internal.tasks.TaskListener
    public void onError(final Throwable th) {
        if (this._onEDT) {
            new Thread(new Runnable() { // from class: com.esri.core.tasks.ags.TaskCallbackListener.2
                @Override // java.lang.Runnable
                public void run() {
                    TaskCallbackListener.this._callback.onError(th);
                }
            }).start();
        } else {
            this._callback.onError(th);
        }
    }
}
